/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package scrabble;

import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.LineBorder;

/**
 *
 * @author KhoufiAsma
 */
public final class Horloge extends JPanel{
 int m;
 int s;
 int h;
 JLabel l;
 
  public Horloge( ) {
    m=0;
    s=0;
    h=0;
    l=new JLabel("00:00:00");
  l.setBounds(1100, 500, 200, 50);
  add(l);
  this.setBorder(new LineBorder(Color.BLUE,5));
  this.setBackground(Color.WHITE);
this.setBounds(1100,50,200,50);
  javax.swing.Timer t = new javax.swing.Timer(1000, new ClockListener());
        t.start();
    
  }
 
  public void incremente() {
      s++;
      if(s==60)
      {s=0;
        m++;
      }
      if(m==60)
      {m=0;
      h++;
      }
     
      l.setText(String.format("%02d:%02d:%02d",h,m,s));
  
}
  class ClockListener implements ActionListener {
      @Override
        public void actionPerformed(ActionEvent e) {
            incremente();
        }
  
    }
}
  

 